/*
 * Copyright 2008 Max Kugland
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.splink.library.observer {
	import org.splink.library.IFinalizable;

	/**
	 * Basic Interface for <code>ISubject</code> implementations.
	 * 
	 * <code>IObservers</code> can subscribe to an <code>ISubject</code> to get
	 * notified by the <code>ISubject</code> if it changes. 
	 * 
	 * @author Max Kugland
	 */
	public interface ISubject extends IFinalizable {
		/**
		 * A object which implements <code>IObserver</code> can subscribe to an <code>ISubject</code>
		 *
		 * @param observer the subscribing <code>IObserver</code>
		 */
		function subscribe(observer : IObserver) : void;

		/**
		 * A object which implements <code>IObserver</code> can unsubscribe from an <code>ISubject</code>
		 * 
		 * @param observer the unsubscribing <code>IObserver</code>
		 */
		function unsubscribe(observer : IObserver) : void;

		/**
		 * If the <code>ISubject</code> implementing class invokes the notify method, the update
		 * method of all <code>IObserver</code> subscribing objects gets called.
		 * The <code>ISubject</code> can push additional data to the <code>IObserver</code> objects
		 * update method through the data parameter.
		 * 
		 * @param data additional data which can be pushed to the subscribed <code>IObserver</code> 
		 * objects
		 */
		function notify(data : * = null) : void;
	}
}
